<html>
  <head>
    <title>A canvas linearGradient example</title>
    <meta name="DC.creator" content="Kamiel Martinet, http://www.martinet.nl/">
    <meta name="DC.publisher" content="Mozilla Developer Center, http://developer.mozilla.org">

	<!--[if IE]><script type="text/javascript" src="../excanvas.js"></script><![endif]-->

    <script>
      function boot() {
        draw(document.getElementById('canvas').getContext('2d'));
        draw(document.getElementById('vmlcanvas').getContext('2d'));
      }
      function draw(ctx) {
          ctx.translate(-10, 5);
//          ctx.scale(1.2, 0.8);
          ctx.rotate(5 * Math.PI / 180);

        // Create gradients
        var lingrad = ctx.createLinearGradient(0,0,0,150);
        lingrad.addColorStop(0, '#00ABEB');
        lingrad.addColorStop(0.5, '#fff');
        lingrad.addColorStop(0.5, '#66CC00');
        lingrad.addColorStop(1, '#fff');

        var lingrad2 = ctx.createLinearGradient(0,50,0,95);
        lingrad2.addColorStop(0.5, '#000');
        lingrad2.addColorStop(1, 'rgba(0,0,0,0)');

        // assign gradients to fill and stroke styles
        ctx.fillStyle = lingrad;
        ctx.strokeStyle = lingrad2;

        // draw shapes
        ctx.fillRect(10,10,130,130);
        ctx.strokeRect(50,50,50,50);
      }
    </script>
    <style type="text/css">
      body { margin: 20px; font-family: arial,verdana,helvetica; background: #fff;}
      h1 { font-size: 140%; font-weight:normal; color: #036; border-bottom: 1px solid #ccc; }
      canvas { border: 2px solid #000; float: left; margin-right: 20px; margin-bottom: 20px; }
      pre { float:left; display:block; background: rgb(238,238,238); border: 1px dashed #666; padding: 15px 20px; margin: 0 0 10px 0; }
    </style>
  </head>
  <body onload="boot();">
    <h1>A canvas <code>linearGradient</code> example</h1>
    <div>
      <canvas id="canvas" width="150" height="150"></canvas>
      <canvas id="vmlcanvas" class="vml" width="150" height="150"></canvas>
      <pre>
function boot() {
  draw(document.getElementById('canvas').getContext('2d'));
  draw(document.getElementById('vmlcanvas').getContext('2d'));
}
function draw(ctx) {
    ctx.translate(-10, 5);
//    ctx.scale(1.2, 0.8);
    ctx.rotate(5 * Math.PI / 180);

  // Create gradients
  var lingrad = ctx.createLinearGradient(0,0,0,150);
  lingrad.addColorStop(0, '#00ABEB');
  lingrad.addColorStop(0.5, '#fff');
  lingrad.addColorStop(0.5, '#66CC00');
  lingrad.addColorStop(1, '#fff');

  var lingrad2 = ctx.createLinearGradient(0,50,0,95);
  lingrad2.addColorStop(0.5, '#000');
  lingrad2.addColorStop(1, 'rgba(0,0,0,0)');

  // assign gradients to fill and stroke styles
  ctx.fillStyle = lingrad;
  ctx.strokeStyle = lingrad2;
  
  // draw shapes
  ctx.fillRect(10,10,130,130);
  ctx.strokeRect(50,50,50,50);

}
      </pre>
    </div>
  </body>
</html>
